<%@ page contentType="text/html;charset=UTF-8"%>
<script type="text/javascript">
	//是否服务器分页
	var _isServerPage = true;
	//表格列定义
	var _tableCols = 	[{
		data : "uuid",
		sortable : false,
		className : "center",
		width : "30",
		render : RapDataTableUtils.renderCheckCol
	},
	{
		data : 'theName',
		width : "120",
		render : function(data, type, full) {
			return RapDataTableUtils.renderStrByLength(data,24);
		},
		sortable : true
	},
	{
		data : 'totalArea',
		width : "120",
		className :"rap-td-number",
		render:milliFormat,
		sortable : true
	},
	{
		data : 'remark',
		width : "120",
		render : function(data, type, full) {
			return RapDataTableUtils.renderStrByLength(data,28);
		},
		sortable : true
	},
	{
		data : "uuid",
		className : "center",
		sortable : false,
		render : function(data, type, full) {
			return "<div class='rap-btn-actiongroup'>" 
			+ "<button id='rap-btn-view-row' class='btn btn-xs btn-success' data-rel='tooltip' title='查看'><i class='fa fa-search-plus'></i></button>"
			<shiro:hasPermission name="stwy:pro:property:update">
			+ "<button id='rap-btn-edit-row' class='btn btn-xs btn-info' data-rel='tooltip' title='编辑'><i class='fa fa-edit'></i></button>"
			</shiro:hasPermission>
			<shiro:hasPermission name="stwy:pro:property:delete">
			+ "<button id='rap-btn-remove-row' class='btn btn-xs btn-danger' data-rel='tooltip' title='删除'><i class='fa fa-trash-o'></i></button>"
			</shiro:hasPermission>
			+ "</div>";
		},
		width : "80"
	}]
;

	//宏：生成ShowData方法，在编辑框显示记录数据
	function showData(data) {
		$("input[name='uuid']").val(data.uuid);
		$("input[name='theCode']").val(data.theCode);
		$("input[name='totalArea']").val(data.totalArea);
		$("input[name='theName']").val(data.theName);
		$("textarea[name='remark']").val(data.remark);
	}
	//查询前处理面积查询条件
	function doBeforeQuery(){
		var compareType = $("#compareType").val();
		if(compareType!=null){
			if(compareType=="1"){
				$("#search_totalArea").attr("name","search_GTE_totalArea");
			}else if(compareType=="2"){
				$("#search_totalArea").attr("name","search_LTE_totalArea");
			}
		}
	}
	//绑定除了默认事件外的其他事件
	function bindOtherAction(){
		$("#rap-form-edit input[name='theName']").bind('blur',function(){
			checkRepeat(this,true);
		});
	}
	$(document).ready(function() {
		bindDefaultActions();
		bindOtherAction();
		_queryData = $("#rap-form-query").serializeArray();
		var url = '${serviceurl}/query';
		if(_isServerPage){
			//服务器分页
			serverPage(url);	
		}else{
			//非服务器分页
			_tableList = $('#rap-table-list').DataTable({
				"columns" : _tableCols,
				"createdRow" : RapDataTableUtils.setActions,
				"order": [] 
			});
			loadList(url);		
		}
		
		RapDataTableUtils.setCheckCol(_tableList);
		/**
		 * 表单校验
		 */
		_validator = $('#rap-form-edit').validate({
					rules : {
						theName : {
							required : true
						},
						totalArea : {
							required : true,
							isFloat : true
						}
					},
					messages : {
						totalArea : {
							isFloat : "请输入数字"
						}
					}
				});
	});
</script>